package com.example.myfiveapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GoodsAdapter extends ArrayAdapter<Goods> {

    private int resourceId;

    public GoodsAdapter(Context context, int textViewResourceId,
                        java.util.List<Goods> objects) {
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position , View convertView, ViewGroup parent) {
        Goods goods = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        TextView goodsIndex = (TextView) view.findViewById(R.id.goods_index);
        TextView goodsName = (TextView) view.findViewById(R.id.goods_name);
        TextView goodsNumber = (TextView) view.findViewById(R.id.goods_number);
        goodsIndex.setText(goods.getIndex());
        goodsName.setText(goods.getName());
        goodsNumber.setText(goods.getNumber());
        return view;
    }
}